<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUserSpendRecordTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_spend_record', function(Blueprint $table)
        {
            $table->increments('id');
            $table->integer('user_id')->default(0)->comment('用户id');
            $table->integer('books_id')->default(0)->comment('书本或章节id');
            $table->integer('recharge_package_id')->default(0)->comment('阅读币套餐id');
            $table->integer('num')->default(0)->comment('商品数量');
            $table->decimal('amount_money',11,2)->default(0)->comment('购买阅读币所花的金额');
            $table->integer('amount_books_coin')->default(0)->comment('购买书或章节花费的阅读币数量');
            $table->string('remark')->nullable()->comment('备注');
            $table->string('type')->nullable()->comment('消费类型 book整本书/books_coin阅读币');
            $table->tinyInteger('is_pay')->default(0)->comment('是否已支付，0：未支付，1：已支付');
            $table->timestamp('pay_time')->nullable()->comment('支付时间');
            $table->string('pay_type')->nullable()->comment('支付方式：wechat/alipay/pos/books_coin');
            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}
